package com.wiseman.jxgl;

import java.util.ArrayList;

public class Course {

	String date;
	String stage;
	String coach;
	ArrayList<String> students = new ArrayList<String>();
	ArrayList<String> extra_students = new ArrayList<String>();
	String memo;

	public boolean isEmpty() {
		return students.isEmpty();
	}
	
	
	public String getExtraStudentString(){	
		
		String extraStudents = null;
		int extraSize = extra_students.size();
		for (int i = 0; i < extraSize; i++) {
			if (i == 0) {
				extraStudents = extra_students.get(0);
			} else {
				extraStudents += " " + extra_students.get(i);
			}
		}
		
		
		return extraStudents;	}
	
	
	public void getExtraStudentList(String extra){
		if (extra != null) {
			String[] extraStudents = extra.split(" ");
			for (String s : extraStudents) {
				extra_students.add(s);
			}
		}
	}
	

	
	public boolean equals(Course c) {

		boolean ret = (date.equals(c.date) && stage.equals(c.stage)
				&& Util.strSame(coach, c.coach) && Util.strSame(memo, c.memo)
				&& students.size() == c.students.size() && extra_students
				.size() == c.extra_students.size());

		if (ret) {
			int size = students.size();
			for (int i = 0; i < size; i++) {
				if (!students.get(i).equals(c.students.get(i)))
					return false;
			}

			size = extra_students.size();
			for (int i = 0; i < size; i++) {
				if (!extra_students.get(i).equals(c.extra_students.get(i)))
					return false;
			}

		}

		return ret;
	}
}
